import os
import cv2
import utils
from tqdm import tqdm

path_yuv420sp = r'/media/fang/Samsung USB/G410D-0623/G410D-0623/tsr/img/Europe/edge'
path_output = path_yuv420sp

for root, dirs, files in os.walk(path_yuv420sp):
    for file in tqdm(files):
        if file.split('.')[-1] == 'yyy':
            w = int(file.split("_")[-2])
            h = int(file.split("_")[-1][:-7])
            if w > 0:
                gray = utils.y2gray(root + '/' + file, w, h)
                cv2.imwrite(path_output + '/' + file.split(".")[0] + '.jpg', cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR))
